<?php
namespace BP\Sys;

use BP\En\EntityMyPK;

require_once("BP/En/Map.php");
require_once("BP/Tools/DateUtils.php");
require_once("java/text/SimpleDateFormat.php");
class UserRegedit extends EntityMyPK {
	protected $AutoMyPK;	// boolean
	public function getAutoMyPK () 
	{
		return $this->AutoMyPK;
	}
	public function setAutoMyPK ($value) // [boolean value]
	{
		$this->AutoMyPK = $value;
	}
	public function getIsPic () 
	{
		return $this->GetValBooleanByKey(UserRegeditAttr::$IsPic);
	}
	public function setIsPic ($value) // [boolean value]
	{
		$this->SetValByKey(UserRegeditAttr::$IsPic, $value);
	}
	public function getNumKey () 
	{
		return $this->GetValStringByKey(UserRegeditAttr::$NumKey);
	}
	public function setNumKey ($value) // [String value]
	{
		$this->SetValByKey(UserRegeditAttr::$NumKey, $value);
	}
	public function getParas () 
	{
		return $this->GetValStringByKey(UserRegeditAttr::$Paras);
	}
	public function setParas ($value) // [String value]
	{
		$this->SetValByKey(UserRegeditAttr::$Paras, $value);
	}
	public function getGenerSQL () 
	{
		$GenerSQL = $this->GetValStringByKey(UserRegeditAttr::$GenerSQL);
		$GenerSQL = $GenerSQL->replace("~", "'");
		return $GenerSQL;
	}
	public function setGenerSQL ($value) // [String value]
	{
		$this->SetValByKey(UserRegeditAttr::$GenerSQL, $value);
	}
	public function getOrderWay () 
	{
		return $this->GetValStringByKey(UserRegeditAttr::$OrderWay);
	}
	public function setOrderWay ($value) // [String value]
	{
		$this->SetValByKey(UserRegeditAttr::$OrderWay, $value);
	}
	public function getOrderBy () 
	{
		return $this->GetValStringByKey(UserRegeditAttr::$OrderBy);
	}
	public function setOrderBy ($value) // [String value]
	{
		$this->SetValByKey(UserRegeditAttr::$OrderBy, $value);
	}
	public function getFK_Emp () 
	{
		return $this->GetValStringByKey(UserRegeditAttr::$FK_Emp);
	}
	public function setFK_Emp ($value) // [String value]
	{
		$this->SetValByKey(UserRegeditAttr::$FK_Emp, $value);
	}
	public function getDTFrom_Data () 
	{
		$s = $this->GetValStringByKey(UserRegeditAttr::$DTFrom);
		if ($DataType->IsNullOrEmpty($s))
		{
			$ca = $Calendar->getInstance();
			$ca->add($Calendar->DATE, -14);
			$format = new SimpleDateFormat("yyyy-MM-dd");
			return $format->format($ca->getTime());
		}
		return $s->substring(0, 10);
	}
	public function setDTFrom_Data ($value) // [String value]
	{
		$this->SetValByKey(UserRegeditAttr::$DTFrom, $value);
	}
	public function getDTTo_Data () 
	{
		$s = $this->GetValStringByKey(UserRegeditAttr::$DTTo);
		if (($DataType->IsNullOrEmpty($s) || (1 == 1)))
		{
			return $DateUtils->format(new Date(), $DataType->getSysDataFormat());
		}
		return $s->substring(0, 10);
	}
	public function setDTTo_Data ($value) // [String value]
	{
		$this->SetValByKey(UserRegeditAttr::$DTTo, $value);
	}
	public function getDTFrom () 
	{
		return $this->GetValStringByKey(UserRegeditAttr::$DTFrom);
	}
	public function setDTFrom ($value) // [String value]
	{
		$this->SetValByKey(UserRegeditAttr::$DTFrom, $value);
	}
	public function getDTTo () 
	{
		return $this->GetValStringByKey(UserRegeditAttr::$DTTo);
	}
	public function setDTTo ($value) // [String value]
	{
		$this->SetValByKey(UserRegeditAttr::$DTTo, $value);
	}
	public function getDTFrom_Datatime () 
	{
		$s = $this->GetValStringByKey(UserRegeditAttr::$DTFrom);
		if ($DataType->IsNullOrEmpty($s))
		{
			$ca = $Calendar->getInstance();
			$ca->add($Calendar->DATE, -14);
			$format = new SimpleDateFormat("yyyy-MM-dd");
			return $format->format($ca->getTime());
		}
		return $s;
	}
	public function setDTFrom_Datatime ($value) // [String value]
	{
		$this->SetValByKey(UserRegeditAttr::$DTFrom, $value);
	}
	public function getDTTo_Datatime () 
	{
		$s = $this->GetValStringByKey(UserRegeditAttr::$DTTo);
		if ($DataType->IsNullOrEmpty($s))
		{
			return $DateUtils->format(new Date(), $DataType->getSysDataTimeFormat());
		}
		return $s;
	}
	public function setDTTo_Datatime ($value) // [String value]
	{
		$this->SetValByKey(UserRegeditAttr::$DTTo, $value);
	}
	public function getCfgKey () 
	{
		return $this->GetValStringByKey(UserRegeditAttr::$CfgKey);
	}
	public function setCfgKey ($value) // [String value]
	{
		$this->SetValByKey(UserRegeditAttr::$CfgKey, $value);
	}
	public function getSearchKey () 
	{
		return $this->GetValStringByKey(UserRegeditAttr::$SearchKey);
	}
	public function setSearchKey ($value) // [String value]
	{
		$this->SetValByKey(UserRegeditAttr::$SearchKey, $value);
	}
	public function getVals () 
	{
		return $this->GetValStringByKey(UserRegeditAttr::$Vals);
	}
	public function setVals ($value) // [String value]
	{
		$this->SetValByKey(UserRegeditAttr::$Vals, $value);
	}
	public function getMVals () 
	{
		return $this->GetValStringByKey(UserRegeditAttr::$MVals);
	}
	public function setMVals ($value) // [String value]
	{
		$this->SetValByKey(UserRegeditAttr::$MVals, $value);
	}
	public static function constructor__ () 
	{
		$me = new self();
		$me->setAutoMyPK( TRUE );
		return $me;
	}
	public static function constructor__String_String ($fk_emp, $cfgkey) // [String fk_emp, String cfgkey]
	{
		$me = new self();
		parent::constructor__();
		$me->setMyPK(($fk_emp . $cfgkey));
		$me->setCfgKey($cfgkey);
		$me->setFK_Emp($fk_emp);
		$i = $me->RetrieveFromDBSources();
		if (($i == 0))
		{
			$me->setCfgKey($cfgkey);
			$me->setFK_Emp($fk_emp);
			$me->DirectInsert();
		}
		return $me;
	}
	public function getEnMap () 
	{
		if (($this->get_enMap() != NULL))
		{
			return $this->get_enMap();
		}
		$map = new Map("Sys_UserRegedit", "用户注册�?");
		$map->Java_SetDepositaryOfEntity($Depositary->None);
		$map->Java_SetDepositaryOfMap($Depositary->Application);
		$map->Java_SetEnType($EnType->Sys);
		$map->AddMyPK();
		$map->AddTBString(UserRegeditAttr::$FK_Emp, NULL, "用户",  FALSE ,  FALSE , 0, 30, 20);
		$map->AddTBString(UserRegeditAttr::$CfgKey, NULL, "�?",  TRUE ,  FALSE , 0, 200, 20);
		$map->AddTBString(UserRegeditAttr::$Vals, NULL, "�?",  TRUE ,  FALSE , 0, 2000, 20);
		$map->AddTBString(UserRegeditAttr::$GenerSQL, NULL, "GenerSQL",  TRUE ,  FALSE , 0, 2000, 20);
		$map->AddTBString(UserRegeditAttr::$Paras, NULL, "Paras",  TRUE ,  FALSE , 0, 2000, 20);
		$map->AddTBString(UserRegeditAttr::$NumKey, NULL, "分析的Key",  TRUE ,  FALSE , 0, 300, 20);
		$map->AddTBString(UserRegeditAttr::$OrderBy, NULL, "OrderBy",  TRUE ,  FALSE , 0, 300, 20);
		$map->AddTBString(UserRegeditAttr::$OrderWay, NULL, "OrderWay",  TRUE ,  FALSE , 0, 300, 20);
		$map->AddTBString(UserRegeditAttr::$SearchKey, NULL, "SearchKey",  TRUE ,  FALSE , 0, 300, 20);
		$map->AddTBString(UserRegeditAttr::$MVals, NULL, "MVals",  TRUE ,  FALSE , 0, 2000, 20);
		$map->AddBoolean(UserRegeditAttr::$IsPic,  FALSE , "是否图片",  TRUE ,  FALSE );
		$map->AddTBString(UserRegeditAttr::$DTFrom, NULL, "查询时间�?",  TRUE ,  FALSE , 0, 20, 20);
		$map->AddTBString(UserRegeditAttr::$DTTo, NULL, "�?",  TRUE ,  FALSE , 0, 20, 20);
		$map->AddTBAtParas(4000);
		$this->set_enMap($map);
		return $this->get_enMap();
	}
	public function getGetNewEntities () 
	{
		return UserRegedits::constructor__();
	}
	protected function beforeUpdateInsertAction () 
	{
		return parent->beforeUpdateInsertAction();
	}
	public function GetVals () 
	{
		if ($DataType->IsNullOrEmpty($this->getVals()))
		{
			return []; //
		}
		$arr = NULL;
		$strs = $this->getVals()->split("@");
		$idx = -1;
		$kvs = []; //
		foreach ($strs as $str) 		{
			$idx = $str->indexOf('=');
			if (($idx == -1))
			{
				continue;
			}
			$kvs->put($str->substring(0, $idx), ( (($idx == ($str->length() - 1))) ? "" : $str->substring(($idx + 1)) ));
		}
		return $kvs;
	}
	public static function HaveRoleForImp ($ensName) // [String ensName]
	{
		$ur = UserRegedit::constructor__String_String("admin", ($ensName . "_SearchAttrs"));
		$impEmps = (new AtPara($ur->getParas()))->GetValStrByKey("ImpEmpNos");
		if ($DataType->IsNullOrEmpty($impEmps))
		{
			return  TRUE ;
		}
		else
		{
			return ($WebUser->getNo()->equals("admin") || (((("," . $impEmps) . ","))->indexOf((("," . $WebUser->getNo()) . ",")) != -1));
		}
	}
	public static function HaveRoleForExp ($ensName) // [String ensName]
	{
		$ur = UserRegedit::constructor__String_String("admin", ($ensName . "_SearchAttrs"));
		$impEmps = (new AtPara($ur->getParas()))->GetValStrByKey("ExpEmpNos");
		if ($DataType->IsNullOrEmpty($impEmps))
		{
			return  TRUE ;
		}
		else
		{
			return ($WebUser->getNo()->equals("admin") || (((("," . $impEmps) . ","))->indexOf((("," . $WebUser->getNo()) . ",")) != -1));
		}
	}
}
?>
